from django.contrib.auth.models import User
from django.db import models


# Create your models here.

class Topic(models.Model):
    """学习主题"""
    text = models.CharField(max_length=200)
    date_added = models.DateTimeField(auto_now_add=True)
    ower = models.ForeignKey(User)


    def __str__(self):
        '''返回模型的字符串标示'''
        return self.text


class Entry(models.Model):
    topic = models.ForeignKey(Topic)
    text = models.TextField()
    date_added = models.DateTimeField(auto_now_add=True)

    class Meta:
        verbose_name_plural = 'entries'

    def __str__(self):
        return self.text[:50] + '...'
